export function checkTimeRange(newStart: string, newEnd: string,DateArr:any) {
    // 格式化时间，将时间小时+分钟+秒，都转换成秒
    console.log('第一',newStart,'第二',newEnd)
    const timeRegex = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/
    console.log(timeRegex.test(newStart),66666666,timeRegex.test(newEnd))
    if (!timeRegex.test(newStart) || !timeRegex.test(newEnd)) {
        return '时间格式错误'
    }
    const timeToSeconds = (timeStr: any) => {
        const [hours, minutes, seconds] = timeStr.split(':').map(Number)
        return hours * 3600 + minutes * 60 + seconds
    }
    const newStartSec = timeToSeconds(newStart)
    const newEndSec = timeToSeconds(newEnd)
    if (newStartSec > newEndSec) {
        return '开始时间不能大于结束时间'
    }
    for (const item of DateArr) {
        const existStartSec = timeToSeconds(item.data1)
        const existEndSec = timeToSeconds(item.data2)
        if (newStartSec <= existEndSec && newEndSec >= existStartSec) {
            return `与已有区间 ${item.data1}-${item.data2} 重叠，不允许选择`
        }
    }
    return 
}
